package cn.tedu.toa.management.sys.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.time.format.DateTimeFormatter;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 角色
 * </p>
 *
 * @author huaqian
 * @since 2021-09-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_roles")
@Accessors(chain = true)
public class SysRoles extends Model<SysRoles> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 角色名称
     */
    @TableField("name")
    private String name;

    /**
     * 备注
     */
    @TableField("note")
    private String note;

    /**
     * 创建时间
     */
    @TableField("createdTime")
    private LocalDateTime createdTime;

    /**
     * 修改时间
     */
    @TableField("modifiedTime")
    private LocalDateTime modifiedTime;

    /**
     * 创建用户
     */
    @TableField("createdUser")
    private String createdUser;

    /**
     * 修改用户
     */
    @TableField("modifiedUser")
    private String modifiedUser;


    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @TableField(exist = false)
    private String createdTimeStr;
    @TableField(exist = false)
    private String modifiedTimeStr;

    public String getCreatedTimeStr() {
        if(this.createdTime!=null){
            DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            this.createdTimeStr=dtf.format(this.createdTime);
        }
        return this.createdTimeStr;
    }

    public String getModifiedTimeStr() {
        if(this.modifiedTime!=null){
            DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            this.modifiedTimeStr=dtf.format(this.modifiedTime);
        }
        return this.modifiedTimeStr;
    }
}
